package com.wujiahui.wiki.controller;
import com.wujiahui.wiki.req.EbookQueryReq;
import com.wujiahui.wiki.req.EbookSaveReq;
import com.wujiahui.wiki.resp.PageResp;
import com.wujiahui.wiki.service.EbookService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;
import com.wujiahui.wiki.resp.CommonResp;
import com.wujiahui.wiki.resp.EbookQueryResp;

@RestController
@RequestMapping("/ebook")
public class EbookController {
    @Resource
    private EbookService ebookService;
    @GetMapping("/list")
    public CommonResp list(@Valid EbookQueryReq req){
        CommonResp<PageResp<EbookQueryResp>> resp =new CommonResp<>();
        PageResp<EbookQueryResp> list =ebookService.list(req);
        resp.setContent(list);
        return resp;
    }

    @PostMapping("/save")
    public CommonResp save(@Valid EbookSaveReq req){
        CommonResp resp =new CommonResp<>();
        ebookService.save(req);
        return resp;
    }



    @DeleteMapping("/delete/{id}")
public CommonResp delets(@PathVariable Long id){
    CommonResp resp = new CommonResp<>();
    ebookService.delete(id);
    return  resp;
    }
}